package org.streets.eis.ext.analysis;

import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.ScopeConstants;
import org.apache.tapestry5.ioc.annotations.Scope;
import org.slf4j.Logger;
import org.streets.database.SQLConnection;
import org.streets.database.datadict.DataDict;
import org.streets.database.datadict.TableRelations;
import org.streets.eis.ext.analysis.internal.impl.QueryDAOImpl;
import org.streets.eis.ext.analysis.internal.impl.QueryServiceImpl;
import org.streets.eis.ext.analysis.services.QueryDAO;
import org.streets.eis.ext.analysis.services.QueryService;
import org.streets.annotations.Detail;
import org.streets.annotations.Portal;
 
 

@Detail(id = "PUBQUERY", name = "通用查询模块", hint = "查询", icon = "xxxx", index = 3)
@Portal(value = "org.streets.eis.ext.analysis.pages.ExecQueryPage")
public class AnalysisModule {

	public void contributeEntityPackageManager(Configuration<String> configuration) {
		configuration.add("org.streets.eis.ext.analysis.entities");
	}

	//public QueryBuilder buildQueryBuilder(Logger logger, DataDict dict,TableRelations relations, SQLConnection connection,QueryService queryService) { 
	//	QueryBuilder queryBuilder = new QueryBuilderImpl(logger, dict,relations, connection); 
	//	return queryBuilder;
	//}
	
	@Scope(ScopeConstants.PERTHREAD)
	public QueryDAO buildQueryDAO(SQLConnection connection) {		
		return new QueryDAOImpl(connection);
	}

	@Scope(ScopeConstants.PERTHREAD)
	public QueryService buildQueryService(Logger logger, SQLConnection connection,DataDict dict,TableRelations relations) { 
		  QueryService service = new QueryServiceImpl(logger,dict,relations,connection); 
		  return service;
	}
	
	public void contributeTableRelations(Configuration<String> configuration) {
		configuration.add("EIS_CODE_GROUP.id->EIS_CODE_ITEM.group_id");		
		configuration.add("EIS_ANALYSIS_TEST1.id->EIS_ANALYSIS_TEST2.testTable1_id");
		configuration.add("EIS_ANALYSIS_TEST2.id->EIS_ANALYSIS_TEST3.testTable2_id");		
	}
	
	
}

